using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using BusinessObjects;

namespace GUI
{
    public partial class frmProfiles : Form
    {
        public frmProfiles()
        {
            InitializeComponent();
        }
        ChameleonManager insChameleonManager = new ChameleonManager();
        private void frmProfiles_Load(object sender, EventArgs e)
        {
            LoadGridData();
        }

        private void btnNewProfile_Click(object sender, EventArgs e)
        {
            frmProfilesEdit insFrmProfilesEdit = new frmProfilesEdit();
            insFrmProfilesEdit.ShowDialog();
            LoadGridData();
        }
        private void LoadGridData()
        {
            dgvProfiles.DataSource = insChameleonManager.GetProfilesDataTable();
        }
        private void dgvProfiles_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex != -1)
            {
                if (e.ColumnIndex == 0)
                {
                    Profile insProfile = new Profile();
                    insProfile = insChameleonManager.GetProfile(dgvProfiles.Rows[e.RowIndex].Cells["clmnProfileName"].Value.ToString());
                    frmProfilesEdit insFrmProfilesEdit = new frmProfilesEdit(insProfile);
                    insFrmProfilesEdit.ShowDialog();
                    LoadGridData();

                }
                else if (e.ColumnIndex == 1)
                {
                    insChameleonManager.DeleteProfile(dgvProfiles.Rows[e.RowIndex].Cells["clmnProfileName"].Value.ToString());
                    LoadGridData();
                }
            }
        }
    }
}